home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Utilities / Text and Speech / BBEdit 2.2.2 / BBEdit Extensions / Sources / DialogUtilities.c < prev    next >
C/C++ Source or Header  |  1992-09-08  |  1KB  |  62 lines

  1. #include "DialogUtilities.h"
  2.  
  3. Handle GetIHandle(DialogPtr d, short item)
  4. {
  5.     Rect r;
  6.     Handle h;
  7.     short iType;
  8.     
  9.     GetDItem(d, item, &iType, &h, &r);
  10.     return h;
  11. }
  12.  
  13. void SetStrItem(DialogPtr d, short item, unsigned char s[])
  14. {
  15.     Handle h = GetIHandle(d, item);
  16.     SetIText(h, s);
  17. }
  18.  
  19. void ReadStrItem(DialogPtr d, short item, unsigned char s[])
  20. {
  21.     Handle h = GetIHandle(d, item);
  22.     GetIText(h, s);
  23. }
  24.  
  25. void SetDlgCtl(DialogPtr d, short item, Boolean flag)
  26. {
  27.     ControlHandle c = (ControlHandle)GetIHandle(d, item);
  28.     
  29.     SetCtlValue(c, flag);
  30. }
  31.  
  32. Boolean GetDlgCtl(DialogPtr d, short item)
  33. {
  34.     ControlHandle c = (ControlHandle)GetIHandle(d, item);
  35.     
  36.     return GetCtlValue(c);
  37. }
  38.  
  39. Boolean TestDlgCtl(DialogPtr d, short item)
  40. {
  41.     ControlHandle c = (ControlHandle)GetIHandle(d, item);
  42.     
  43.     return ((**c).contrlHilite != 0xFF);
  44. }
  45.  
  46. void XAbleDlgCtl(DialogPtr d, short item, Boolean flag)
  47. {
  48.     ControlHandle c = (ControlHandle)GetIHandle(d, item);
  49.     
  50.     HiliteControl(c, flag ? 0 : 0xFF);
  51. }
  52.  
  53. void SetupUserItem(DialogPtr d, short item, pascal void (*ItemProc)(DialogPtr d, short item))
  54. {
  55.     short type;
  56.     Handle handle;
  57.     Rect rect;
  58.     
  59.     GetDItem(d, item, &type, &handle, &rect);
  60.     SetDItem(d, item, type, (Handle)ItemProc, &rect);
  61. }
  62.